import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { registerMicroApps, start } from 'qiankun';
import { BrowserRouter, Routes, Route } from 'react-router-dom';

createRoot(document.getElementById('rootmain')!).render(
  <StrictMode>
    app1
    <div id="childrenRoot">childrenRoot</div>
    <BrowserRouter basename='app1'>
      <Routes>
        <Route path="/" element={<div>app1</div>} />
        <Route path="/App1children" element={<div>app1children</div>} />
      </Routes>
    </BrowserRouter>
  </StrictMode>,
)
registerMicroApps([
  {
    name: 'app2', // app name registered
    entry: import.meta.env.MODE === 'development' ? 'http://localhost:5174' : '/app2',
    container: '#childrenRoot',
    activeRule: '/app1/app2',
  },
]);

start();